package com.example.demo.Controller;

import com.example.demo.Controller.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component//@Bean要配合类注解使用
public class BeanConfig {

//    @Bean(name = {"u1", "user1"})//可以指定多个名称
////    @Bean({"u1","user1"})//name=可以省略
////    @Bean("u1")//只用一个名称时name=和{}都可以省略
    @Primary
    @Bean
    public User user1(){
        User user = new User();
        user.setName("zhangsan");
        user.setAge(18);
        user.setGender("男");
        return user;
    }


    @Bean
    public User user2(){
        User user = new User();
        user.setName("lisi");
        user.setAge(81);
        user.setGender("女");
        return user;
    }
}
